{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Tensor(\"Add:0\", shape=(), dtype=float32)\n"
     ]
    }
   ],
   "source": [
    "import tensorflow.compat.v1 as tf\n",
    "tf.disable_eager_execution()\n",
    "node1 = tf.constant(3.0,dtype=tf.float32,name=\"node1\")\n",
    "node2 = tf.constant(4.0,dtype=tf.float32,name=\"node2\")\n",
    "node3 = tf.add(node1,node2)\n",
    "print(node3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "3.0\n",
      "4.0\n",
      "7.0\n"
     ]
    }
   ],
   "source": [
    "sess = tf.Session()\n",
    "print(sess.run(node1))\n",
    "print(sess.run(node2))\n",
    "print(sess.run(node3))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "2\n",
      "3\n",
      "4\n",
      "5\n",
      "6\n",
      "7\n",
      "8\n",
      "9\n",
      "10\n"
     ]
    }
   ],
   "source": [
    "value = tf.Variable(0,name=\"value\")\n",
    "one = tf.constant(1,name = \"one\")\n",
    "new_value = tf.add(value,one)\n",
    "update_value = tf.assign(value,new_value)\n",
    "initer = tf.global_variables_initializer()\n",
    "with tf.Session() as sess:\n",
    "    sess.run(initer)\n",
    "    for i in range(10):\n",
    "        sess.run(update_value)\n",
    "        print(sess.run(value))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "3\n",
      "6\n",
      "10\n",
      "15\n",
      "21\n",
      "28\n",
      "36\n",
      "45\n",
      "55\n"
     ]
    }
   ],
   "source": [
    "container = tf.Variable(0,name= \"container\")\n",
    "Adder = tf.Variable(0,name= \"adder\")\n",
    "one = tf.constant(1,name=\"one\")\n",
    "add_adder = tf.add(Adder,one)\n",
    "update_adder = tf.assign(Adder,add_adder)\n",
    "new_container = tf.add(container,Adder)\n",
    "update_container = tf.assign(container,new_container)\n",
    "init = tf.global_variables_initializer()\n",
    "with tf.Session() as sess:\n",
    "    sess.run(init)\n",
    "    for i in range(10):\n",
    "        sess.run(update_adder)\n",
    "        sess.run(update_container)\n",
    "        print(sess.run(container))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
